package edu.uow.devdocs
/**
 * The Deployment entity.
 *
 * @author    
 *
 *
 */
class Deployment {
	static auditable = true
    static mapping = {
         table 'DEPLOYMENT'
         // version is set to false, because this isn't available by default for legacy databases
         version false
         id column:'DEPLOYMENT_ID'
         project column:'SUB_SYSTEM_ID'
         status column:'STATUS_ID'
		 id generator: 'sequence', params:[sequence:'DEPLOYMENT_SEQ']
		 sort deploymentVersion:'ASC'
    }
    String deploymentVersion
    Date dateOfPlannedDeployment
    Date dateOfActualDeployment
    String referenceNumber
    Date dateOfPlannedTestDeploy
    Date dateOfActualTestDeploy
    Date lastUpdated
    // Relation
    Project project
    // Relation
    DeploymentStatus status
	
	//List developmentTasks
	
	static hasMany = [developmentTasks: DevelopmentTask]
	
	

    static constraints = {
        deploymentVersion(size: 1..20)
        dateOfPlannedDeployment(nullable: true)
        dateOfActualDeployment(nullable: true)
        referenceNumber(nullable:true,size: 0..20)
        dateOfPlannedTestDeploy(nullable: true)
        dateOfActualTestDeploy(nullable: true)
        lastUpdated(nullable: true)
        project(nullable:false)
        status()
    }
	
	static namedQueries = {
		active {
			'in' 'status', DeploymentStatus.active.list()
		}
	}
	
    String toString() {
        return "${project} ${deploymentVersion}"
    }
	
	
}
